<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<%@ taglib prefix="form" uri="http://www.springframework.org/tags/form"%>
<div class="xsnazzy">
	<h1>Uus kliendipöördumine</h1>
	<form:form method="POST" commandName="newServiceRequestForm" id="frm1">
		<br>
		<table>
			<tr>
				<td vAlign="top"><b>Klient</b></td>
                <td>
                    <select name="customerFk">
                        <c:forEach items="${customers}" var="cust">
                            <option value="${cust.customer}"><c:out value="${cust.subject.firstName}"/> <c:out value="${cust.subject.lastName}"/></option>
                        </c:forEach>
                    </select></td>
			</tr>
			<tr>
				<td vAlign="top"><b>Kliendi märkused</b></td>
				<td><form:textarea path="serviceDescByCustomer" rows="5"
						cols="60" /></td>
			</tr>
			<tr>
				<td vAlign="top"><b>Töötaja märkused</b></td>
				<td><form:textarea path="serviceDescByEmployee" rows="5"
						cols="60" /></td>
			</tr>
			<tr>
				<td vAlign="top"><b>Töö staatus</b></td>
				<td>
				    <select name="serviceRequestStatusTypeFk">
				        <c:forEach items="${statuses}" var="stat">
				            <option value="${stat.serviceRequestStatusType}"><c:out value="${stat.typeName}"/></option>
				        </c:forEach>
				    </select></td>
			</tr>
			<tr>
				<td colspan="2"><a
					href="javascript:document.getElementById('frm1').submit()"
					class="btn"><span>Salvesta</span> </a></td>
			</tr>
		</table>
	</form:form>
</div>
<br>
<br>


<h2>Varasemad pöördumised</h2>
<table class="lightBg">
	<tbody>
		<tr>
			<th>Klient</th>
			<th>Sisestaja</th>
			<th>created</th>
			<th>Kliendi märkused</th>
			<th>Töötaja märkused</th>
			<th>Töö staatus</th>
		</tr>
		<c:forEach var="request" items="${list}">
			<tr>
                <td>
                <c:forEach items="${customers}" var="cust">
                    <c:if test="${request.customerFk == cust.customer}">
                        <c:out value="${cust.subject.firstName}"/> <c:out value="${cust.subject.lastName}"/>
                    </c:if>
                </c:forEach></td>
                <td>
                <c:forEach items="${employees}" var="emp">
                    <c:if test="${request.createdBy == emp.person.person}">
                        <c:out value="${emp.person.firstName}"/> <c:out value="${emp.person.lastName}"/>
                    </c:if>
                </c:forEach></td>
				<td>${request.created}</td>
				<td>${request.serviceDescByCustomer}</td>
				<td>${request.serviceDescByEmployee}</td>
				<td>
                <c:forEach items="${statuses}" var="stat">
                    <c:if test="${request.serviceRequestStatusTypeFk == stat.serviceRequestStatusType}">
                        <c:out value="${stat.typeName}"/>
                    </c:if>
                </c:forEach></td>
			</tr>
		</c:forEach>
	</tbody>
</table>
